package com.nuc.bigdata.controller;

import com.nuc.bigdata.orm.entity.User;
import com.nuc.bigdata.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author JackLuo
 * @date 2019/10/22
 */
@RestController
@RequestMapping("/oa-user")
public class LoginController {

    private final LoginService loginService;

    @Autowired
    public LoginController(LoginService loginService) {
        this.loginService = loginService;
    }

    @GetMapping("/user")
    public User toLogin(String loginName,String password) throws Exception {
        User user = loginService.login(loginName, password);
        if (!StringUtils.isEmpty(user)) {
            return user;
        }
        return null;
    }
}
